<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css">
</head>
<body>
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">学生成绩管理系统</a></li>
            <li>管理员个人主页</li>
        </ol>
        <h3 class="page-header">个人信息</h3>
        <table class="table table-striped">
            <tr>
                <td>教师编号：</td>
                <td v-text="teacher.tno"></td>
            </tr>
            <tr>
                <td>教师姓名：</td>
                <td v-text="teacher.tname"></td>
            </tr>
            <tr>
                <td>教师年龄：</td>
                <td v-text="teacher.age"></td>
            </tr>
            <tr colspan="2">
                <td><input type="button" value="修改信息" class="btn btn-success btn-sm" @click="updateTeacher(teacher.tno)"></td>
            </tr>
        </table>
        <h3 class="page-header">账号信息</h3>
        <table class="table table-striped">
            <tr>
                <th>昵称</th>
                <th>类别</th>
                <th>邮箱</th>
                <th>操作</th>
            </tr>
            <tr>
                <td v-text="login.loginName"></td>
                <td v-text="Type"></td>
                <td v-text="login.loginEmail"></td>
                <td><input type="button" value="修改密码" class="btn btn-primary btn-sm" @click="updateLogin()"></td>
            </tr>
        </table>
    </div>
    <script src="js/vue/vue2.5.js"></script>
    <script src="js/vue/axios.min.js"></script>
    <script src="js/jquery.js"></script>
    <script src="js/layer/layer.js"></script>
    <script>
        new Vue({
            el:'.container',
            data:{
                teacher:{
                    tno:'',
                    tname:'',
                    age:'',
                },
                login:{
                    loginName:'张三花',
                    loginEmail:'123',
                    loginType:'1',
                    loginId:'',
                },
                Type:''
            },
            methods:{
                //查询
                queryTeacher(){
                    axios.get('/teacher/query',{params:{tno:1001}})
                        .then(resp=>{
                            this.teacher = resp.data;
                        })
                },
                //修改
                updateTeacher(tno) {
                    location.href = 'UpdateAdmin.html?tno=' + tno;
                },
                //账号信息
                queryLogin(){
                    axios.get('/login/query2',{params:{loginId:1}})
                        .then(resp=>{
                            this.login = resp.data;
                            console.log(this.login);
                            if (resp.data.loginType == 1) {
                                this.Type = '管理员';
                            }else {
                                this.Type = '学生';
                            }

                        })
                },
                updateLogin(){
                    location.href = 'UpdateLogin.html?loginId=' + this.login.loginId + '&loginType=' + this.login.loginType;
                }
            },
            mounted() {
                this.queryTeacher();
                this.queryLogin();
            }
        })
    </script>
</body>
</html>